<template>
    <div>
        姓名:
        <input type="text" v-model="cha.name">
        职业:
        <select v-model="cha.xia">
            <option value="0">请选择</option>
            <option v-for="a in datas":value='a.hoteId'>{{a.hoteName}}</option>
        </select>
        <input type="button" value="查询" @click="getdata">
        <input type="button" value="重置" @click="chong">
      <table class="table">
        <thead>
            <tr>
                <td>姓名</td>
                <td>性别</td>
                <td>出生日期</td>
                <td>证件类型</td>
                <td>证件号码</td>
                <td>手机号</td>
                <td>职业</td>
                <td>状态</td>
                <td>详细地址</td>
            </tr>
        </thead>
        <tbody>
            <tr v-for="a in data">
                <td>{{a.userName}}</td>
                <td>{{a.userSex}}</td>
                <td>{{moment(a.userTime).format("YYYY-MM-DD")}}</td>
                <td>{{a.userLei}}</td>
                <td>{{a.userZHao}}</td>
                <td>{{a.userPhone}}</td>
                <td>{{a.hoteName}}</td>
                <td>{{a.userStart==false?'启用':'禁用'}}</td>
                <td>{{a.userAddress}}</td>
            </tr>
        </tbody>
      </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { ref , onMounted, compile } from 'vue';
import { useRouter } from 'vue-router';

onMounted(()=>{
getdata();
xia();
})

const datas = ref([{
    "hoteId": 1,
    "hoteName": "老师"
  },])

  const xia=()=>{
    axios.get("/api/Hote/Show").then(res=>{
    datas.value=res.data
    })
  }

const data = ref([{
    "userId": 1,
    "hoteId": 1,
    "hoteName": "老师",
    "userName": "张三",
    "userLei": 1,
    "userSex": 1,
    "userPhone": "1313232323",
    "userZHao": "1235667767676",
    "userTime": "2025-06-20T00:00:00",
    "userAddress": "北京",
    "userStart": false
  },])

const cha = ref({
    name:'',
    xia:0
})

const chong=()=>{
    cha.value={
        name:'',
    xia:0
    }
}

const getdata=()=>{
    axios.get("/api/User/GetAllAsync",{params:cha.value}).then(res=>{
    data.value = res.data
    })
}

</script>

<style scoped>

</style>